﻿using System;
using System.IO;
using Roslyn.Compilers.CSharp;

namespace Runner
{
    internal class CompilationChecker
    {
        public static void Check(string sourceFilePath)
        {
            if (!File.Exists(sourceFilePath))
            {
                throw new ArgumentException(string.Format("Файл с исходным кодом не найден: {0}", sourceFilePath), "sourceFilePath");
            }

            var fileInfo = new FileInfo(sourceFilePath);
            var sourceFileSyntaxTree = SyntaxTree.ParseCompilationUnit(File.ReadAllText(sourceFilePath), fileInfo.Name);
            var compilation = Compilation.Create("Test", CompilationOptions.Default, new [] { sourceFileSyntaxTree });

//            var syntaxTrees = compilation.SyntaxTrees;
//            foreach (var syntaxTree in syntaxTrees)
//            {
//            }

            var semanticVisitor = new SemanticVisitor();
            semanticVisitor.Visit(compilation.GlobalNamespace);
        }
    }
}
